package org.example.springboot_demo1.controllerRequest.header;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 九转苍翎
 * Date: 2025/7/18
 * Time: 22:22
 */
@RestController
@RequestMapping("/Header")
public class Header {
    //方式1
    @RequestMapping("/getHeader1")
    public String getHeader1(HttpServletRequest request) {
        return request.getHeader("User-Agent");
    }
    //方式2
    @RequestMapping("/getHeader2")
    public String getHeader2(@RequestHeader("User-Agent") String userAgent) {
        return userAgent;
    }
}
